<%@tag pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@tag import="com.oplink.webems.modules.sys.entity.Config"%>
<tags:import includes="bootbox,json,ztree,ztreeCss,scroll,scrollCss"></tags:import>
<script src="${ctxStatic}/modules/sys/commons/tree.js"></script>
<%@ attribute name="url"  type="java.lang.String" required="true"%>
<%@ attribute name="callbackName"  type="java.lang.String" required="false"%>
<%@ attribute name="callbackPIDS"  type="java.lang.String" required="false"%>
<%@ attribute name="callbackPID"  type="java.lang.String" required="false"%>
<%@ attribute name="catalog"  type="java.lang.String" required="false"%>

<input id="selectedPID" type="hidden" value=""/>
<input id="selectedPIDS" type="hidden" value=""/>
<input id="selectedName" type="hidden" value=""/>
<div class="input-group" style="width: 281px;height: 10px;">
<!-- 模态窗体 -->
<div id="modalTree" action="new" class="modal fade"  style="display:none;width:442px;" tabindex="-1">
	<div class="modal-dialog">
		<div class="modal-content" style="width: 440px; height: 347px;">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					<span id='modalTitle'>请选择</span>
				</div>
			</div>
			<br>
			<form id="frmSubmit" class="form-horizontal" role="form" method="post">
			<!-- PAGE START -->
			<div class="form-group">
				<div id="dataTree" style="height:175px;float:left;width:50%;padding-left:11px">
					<ul id="treeView" style="width: 100%;" class="ztree"></ul>
				</div>
				<div style="float:left;width:50%;">
					你选择的是：<span id='chosenMsg' class='red'></span>
				</div>
			</div>
			<div class="space-4"></div>
			<div class="clearfix form-actions">
				<div class="center">
					<button id="btnTreeSubmit" class="btn btn-info" type="button">
						<i class="icon-ok bigger-110"></i> 确定
					</button>					
				</div>
			</div>
			<!-- PAGE CONTENT ENDS -->
			</form>
		</div>
		<!-- /.modal-content -->
	</div>
</div>
<!-- /.modal-dialog -->

<script>
$(document).ready(function(){
	//弹出属性选择框
	$('#btnSelectTree').click(function(){
		$('#modalTree').modal({backdrop:false});			
		$.get(_ctx + '${url}/${catalog}', function(result){
			//初始化树
			var tree = new Tree();
			tree.initTree('treeView', result);
			//展开指定节点。
			tree.zTree.expandAll(true);
			//高亮指定节点
			if($("[name='id']").val() != undefined){
				tree.searchNode($("[name='parentId']").val());
			}
			//准备滚动条
			$('#dataTree').mCustomScrollbar({theme:"minimal-dark"});
		});
	});
	
	//关闭
	$('#btnTreeSubmit').click(function(){
		var callbackName = ('${callbackName}' == undefined) ? 'txtParentId' : '${callbackName}';
		var callbackPID = ('${callbackPID}' == undefined) ? 'hiddenId' : '${callbackPID}';
		var callbackPIDS = ('${callbackPIDS}' == undefined) ? 'hiddenPId' : '${callbackPIDS}';		
		$('#' + callbackName).val($('#selectedName').val());
		$('#' + callbackPID).val($('#selectedPID').val());
		$('#' + callbackPIDS).val($('#selectedPIDS').val());		
		$('#modalTree').modal('hide');
	})
});
</script>